/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package samoloty.view;

import Utils.MyOwnFocusTraversalPolicy;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import samoloty.controler.StartPanelControler;
import sun.java2d.pipe.DrawImage;

/**
 *
 * @author frankowp
 */
public class StartPanel extends ContentPanel {

    private MyLabel title;
    private JLabel picLabel;
    private MyButton okBut;
    private MyLabel leftDownCorner;
    private MyLabel rightDownCorner;
    private MyOwnFocusTraversalPolicy traversalPolicy;

    public StartPanel() {
        super();
        initPanel();
    }

    private void initPanel() {
        setLayout(null);
        title = new MyLabel("THIS APPLICATION IS AUTHORIZED");
        title.setBold();
        okBut = new MyButton("START");
        leftDownCorner = new MyLabel("DATABASE: AHH 550");
        leftDownCorner.setBold();
        rightDownCorner = new MyLabel("MODEL 5593-29288-390");
        rightDownCorner.setBold();

        //focus traversal
        this.setFocusable(false);
        Vector<Component> order = new Vector<Component>();
        order.add(okBut);

        traversalPolicy = new MyOwnFocusTraversalPolicy(order);
        this.setFocusTraversalPolicyProvider(true);
        this.setFocusTraversalPolicy(traversalPolicy);
        this.setFocusCycleRoot(true);
        //--------------

        BufferedImage myPicture = null;
        try {
            String resourcesPath = "Resources/pic.jpg";
            InputStream stream = StartPanel.class.getResourceAsStream(resourcesPath);
            myPicture = ImageIO.read(stream);
             picLabel = new JLabel(new ImageIcon(myPicture));
            add(picLabel);
        } catch (IOException ex) {
            System.out.print(System.getProperty("user.dir")+"\\src\\samoloty\\view\\pic.jpg");
        }
       
        add(title);
        add(okBut);
        add(leftDownCorner);
        add(rightDownCorner);
        okBut.requestFocus();
        picLabel.setBounds(150, 30, 286, 133);
        title.setPosition(new Point(155, 200));
        okBut.setPosition(new Point(250, 260));
        leftDownCorner.setPosition(new Point(5, 520));
        rightDownCorner.setPositionByRight(new Point(570,520));
        this.requestFocus();
        repaint();
        
    }

    public void reset() {
    }

    public void setOKactionListener(ActionListener al) {
        okBut.addActionListener(al);
    }

    public void setFirstFocus(){
        okBut.requestFocus();
    }

}
